<template>
  <el-table border stripe style="width: 100%" row-key="id">
    <!-- 展开 -->
    <el-table-column v-if="$slots.expand" type="expand" class-name="not-sortable">
      <template #default="scope">
        <slot name="expand" :item="scope.row" :index="scope.$index"></slot>
      </template>
    </el-table-column>
    <!-- 多选 -->
    <el-table-column
      class-name="not-sortable"
      v-if="multiple_choice"
      type="selection"
      width="55"
      align="center"
    />
    <!-- 索引 -->
    <el-table-column type="index" v-if="isIndex && !$slots.index" />
    <!-- 自定义索引 -->
    <el-table-column v-if="isIndex && $slots.index" type="index" class-name="not-sortable">
      <template #default="scope">
        <slot name="index" :index="scope.$index + 1"></slot>
      </template>
    </el-table-column>
    <el-table-column
      v-for="(data, index) of props.tableType"
      v-bind="data"
      show-overflow-tooltip
      :class-name="data.className"
      :key="index"
      :align="data.align || 'center'"
    >
      <template v-if="data.header_slot" #header>
        <slot :name="`header_${data.prop}`"></slot>
      </template>
      <template v-if="data.isSlot" #default="scope">
        <slot :name="data.prop" :item="scope.row" :index="scope.$index" :prop="data.prop"></slot>
      </template>
    </el-table-column>
  </el-table>
</template>
<script lang="ts" setup name="T_Table">
import { TablePropType } from '@/interfaces/Element/Table.js'
import { ElTable } from 'element-plus'

/**
 * @return interface
 * **/
interface TableType {
  tableType: Array<TablePropType>
  multiple_choice?: boolean // 是否多选
  isIndex?: boolean
}
/**
 * @return {props,emit}
 * **/
// 默认值
const props = withDefaults(defineProps<TableType>(), {
  multiple_choice: true, // 默认多选
  isIndex: false // 默认无索引
})
/**
 * @return {data,computed}
 * **/

defineExpose({})
</script>
